<!-- $Id: tvd_info.htm 16780 2009-11-09 09:28:30Z sxc_shop $ -->
{include file="pageheader2.htm"}
{insert_scripts files="../js/utils.js,selectzone2.js,validator.js"}
<!-- start goods form -->
<div class="tab-div">
  <div id="tabbar-div">
    <p>
      <span class="tab-front" id="general-tab">{$lang.tab_general}</span>
      <span class="tab-back" id="detail-tab">{$lang.tab_content}</span>
      <span class="tab-back" id="goods-tab">{$lang.tab_goods}</span>
    </p>
  </div>

  <div id="tabbody-div">
    <form  action="tvd.php" method="post" enctype="multipart/form-data" name="theForm" onsubmit="return validate();">
    <table width="90%" id="general-table">
      <tr>
        <td class="narrow-label">{$lang.title}</td>
        <td><input type="text" name="title" size ="40" maxlength="60" value="{$tvd.title|escape}" />不得超过16个字{$lang.require_field}</td>
      </tr>
      <tr>
        <td class="narrow-label">{$lang.title}小</td>
        <td><input type="text" name="title_small" size ="40" maxlength="60" value="{$tvd.title_small|escape}" />不得超过10个字</td>
      </tr>
      <tr>
          <td class="label">作者</td>
          <td>
              <select name="author_id">
                  <option value="0">请选择作者</option>
                  {foreach from=$authorList item=item}
                  <option value="{$item.author_id}" {if !empty($item.selected)}selected{/if}>{$item.author_name}</option>
                  {/foreach}
              </select>
          </td>
      </tr>
      <!-- {if $tvd.cat_id >= 0} -->
      <tr>
        <td class="narrow-label">{$lang.cat} </td>
        <td>
          <select name="tvd_cat" onchange="catChanged()">
            <option value="0">{$lang.select_plz}</option>
            {$cat_select}
          </select>
         {$lang.require_field}</td>
      </tr>
    <tr>
        <td class="label">扩展分类</td>
        <td>
            <input type="button" value="添加" onclick="addOtherCat(this.parentNode)" class="button">
            {foreach from=$tvd.other_cat item=cat_id}
            <select name="other_cat[]"><option value="0">{$lang.select_please}</option>{$other_cat_list.$cat_id}</select>
            {/foreach}
        </td>
    </tr>
      <!-- {else} -->
      <input type="hidden" name="tvd_cat" value="-1" />
      <!-- {/if} -->
      {if $tvd.cat_id >= 0}
      <tr>
        <td class="narrow-label">{$lang.tvd_type}</td>
        <td><input type="radio" name="tvd_type" value="0" {if $tvd.tvd_type eq 0}checked{/if}>{$lang.common}
      <input type="radio" name="tvd_type" value="1" {if $tvd.tvd_type eq 1}checked{/if}>{$lang.top}</td>
      </tr>
      <tr>
        <td class="narrow-label">扩展类型</td>
        <td><input type="radio" name="ext_type" value="0" {if $tvd.tvd_type eq 0}checked{/if}>普通
      <input type="radio" name="ext_type" value="1" {if $tvd.tvd_type eq 1}checked{/if}>涨知识 </td>
      </tr>
      <tr>
        <td class="narrow-label">{$lang.is_open}</td>
        <td>
        <input type="radio" name="is_open" value="1" {if $tvd.is_open eq 1}checked{/if}> {$lang.isopen}
      <input type="radio" name="is_open" value="0" {if $tvd.is_open eq 0}checked{/if}> {$lang.isclose}</td>
      </tr>
      {else}
      <tr style="display:none">
      <td colspan="2"><input type="hidden" name="tvd_type" value="0" /><input type="hidden" name="is_open" value="1" /></td>
      </tr>
      {/if}
      <tr>
        <td class="narrow-label">{$lang.keywords}</td>
        <td><input type="text" name="keywords" maxlength="80" value="{$tvd.keywords|escape}" /></td>
      </tr>
      <tr>
        <td class="narrow-label">{$lang.lable_description}</td>
        <td><textarea name="description" id="description" cols="40" rows="5">{$tvd.description|escape}</textarea></td>
      </tr>
      <tr>
        <td class="narrow-label">上传列表页处理</td>
        <td><input type="file" name="list_img">　　规格：640*280
        </td>
      </tr>
      <tr>
        <td class="narrow-label">上传涨知识专用图片</td>
        <td><input type="file" name="ext_img">　　规格：640*150
        </td>
      </tr>
      <tr>
        <td class="narrow-label">{$lang.upload_file}</td>
        <td><input type="file" name="file">
          <span class="narrow-label">{$lang.file_url}
          <input name="file_url" type="text" value="{$tvd.file_url|escape}" size="30" maxlength="255" />
          </span></td>
      </tr>
    </table>

    <table width="90%" id="detail-table" style="display:none">
     <tr><td>
        {if $old}{$FCKeditor}
        {else}
        <script type="text/javascript" charset="utf-8" src="/includes/ueditor/ueditor.config.js"></script>
        <script type="text/javascript" charset="utf-8" src="/includes/ueditor/ueditor.all.min.js"> </script>
        <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
        <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
        <script type="text/javascript" charset="utf-8" src="/includes/ueditor/lang/zh-cn/zh-cn.js"></script>

        <script id="editor" type="text/plain" style="width:1024px;height:500px;">{$tvd.content}</script>
        <script type="text/javascript">
            delete(Object.prototype.toJSONString);
            //实例化编辑器
            //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
            window.UEDITOR_CONFIG.serverUrl = "/includes/ueditor/php/controller3.php?id={$tvd.tvd_id}&set_url={$smarty.get.set_url}";
            window.UEDITOR_CONFIG.textarea = "FCKeditor1";
            var ue = UE.getEditor('editor');
            function isFocus(e){
                alert(UE.getEditor('editor').isFocus());
                UE.dom.domUtils.preventDefault(e)
            }
            function setblur(e){
                UE.getEditor('editor').blur();
                UE.dom.domUtils.preventDefault(e)
            }
            function insertHtml() {
                var value = prompt('插入html代码', '');
                UE.getEditor('editor').execCommand('insertHtml', value)
            }
            function createEditor() {
                enableBtn();
                UE.getEditor('editor');
            }
            function getAllHtml() {
                alert(UE.getEditor('editor').getAllHtml())
            }
            function getContent() {
                var arr = [];
                arr.push("使用editor.getContent()方法可以获得编辑器的内容");
                arr.push("内容为：");
                arr.push(UE.getEditor('editor').getContent());
                alert(arr.join("\n"));
            }
            function getPlainTxt() {
                var arr = [];
                arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
                arr.push("内容为：");
                arr.push(UE.getEditor('editor').getPlainTxt());
                alert(arr.join('\n'))
            }
            function setContent(isAppendTo) {
                var arr = [];
                arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
                UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
                alert(arr.join("\n"));
            }
            function setDisabled() {
                UE.getEditor('editor').setDisabled('fullscreen');
                disableBtn("enable");
            }

            function setEnabled() {
                UE.getEditor('editor').setEnabled();
                enableBtn();
            }

            function getText() {
                //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
                var range = UE.getEditor('editor').selection.getRange();
                range.select();
                var txt = UE.getEditor('editor').selection.getText();
                alert(txt)
            }

            function getContentTxt() {
                var arr = [];
                arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
                arr.push("编辑器的纯文本内容为：");
                arr.push(UE.getEditor('editor').getContentTxt());
                alert(arr.join("\n"));
            }
            function hasContent() {
                var arr = [];
                arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
                arr.push("判断结果为：");
                arr.push(UE.getEditor('editor').hasContents());
                alert(arr.join("\n"));
            }
            function setFocus() {
                UE.getEditor('editor').focus();
            }
            function deleteEditor() {
                disableBtn();
                UE.getEditor('editor').destroy();
            }
            function disableBtn(str) {
                var div = document.getElementById('btns');
                var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
                for (var i = 0, btn; btn = btns[i++];) {
                    if (btn.id == str) {
                        UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
                    } else {
                        btn.setAttribute("disabled", "true");
                    }
                }
            }
            function enableBtn() {
                var div = document.getElementById('btns');
                var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
                for (var i = 0, btn; btn = btns[i++];) {
                    UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
                }
            }

            function getLocalData () {
                alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
            }

            function clearLocalData () {
                UE.getEditor('editor').execCommand( "clearlocaldata" );
                alert("已清空草稿箱")
            }
        </script>
        {/if}
     </td></tr>
    </table>
    <table width="90%" id="goods-table" style="display:none">
      <!-- 商品搜索 -->
      <tr>
      <td colspan="5">
        <img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
        <!-- 分类 -->
        <select name="cat_id"><option value="0">{$lang.all_category}</option>{$goods_cat_list}</select>
        <!-- 品牌 -->
        <select name="brand_id"><option value="0">{$lang.all_brand}</option>{html_options options=$brand_list}</select>
        <!-- 关键字 -->
        <input type="text" name="keyword" size="30" />
        <input type="button" value="{$lang.button_search}" onclick="searchGoods()" class="button" />
      </td>
      </tr>
      <!-- 商品列表 -->
      <tr>
        <th>{$lang.all_goods}</th>
        <th>{$lang.handler}</th>
        <th>{$lang.send_bouns_goods}</th>
      </tr>
      <tr>
        <td width="45%" align="center">
          <select name="source_select" size="20" style="width:90%" ondblclick="sz.addItem(false, 'add_link_goods', tvdId)" multiple="true">
          </select>
        </td>
        <td align="center">
          <p><input type="button" value="&gt;&gt;" onclick="sz.addItem(true, 'add_link_goods', tvdId)" class="button" /></p>
          <p><input type="button" value="&gt;" onclick="sz.addItem(false, 'add_link_goods', tvdId)" class="button" /></p>
          <p><input type="button" value="&lt;" onclick="sz.dropItem(false, 'drop_link_goods', tvdId)" class="button" /></p>
          <p><input type="button" value="&lt;&lt;" onclick="sz.dropItem(true, 'drop_link_goods', tvdId)" class="button" /></p>
        </td>
        <td width="45%" align="center">
          <select name="target_select" multiple="true" size="20" style="width:90%" ondblclick="sz.dropItem(false, 'drop_link_goods', tvdId)">
            {foreach from=$goods_list item=goods}
            <option value="{$goods.goods_id}">{$goods.goods_name}</option>
            {/foreach}
          </select>
        </td>
      </tr>
    </table>

    <div class="button-div">
      <input type="hidden" name="act" value="{$form_action}" />
      <input type="hidden" name="old_title" value="{$tvd.title}"/>
      <input type="hidden" name="id" value="{$tvd.tvd_id}" />
      <input type="submit" value="{$lang.button_submit}" class="button"  />
      <input type="reset" value="{$lang.button_reset}" class="button" />
    </div>
    </form>
  </div>

</div>
<!-- end goods form -->
<script language="JavaScript">

var tvdId = {$tvd.tvd_id|default:0};
var elements  = document.forms['theForm'].elements;
var sz        = new SelectZone(1, elements['source_select'], elements['target_select'], '');

{literal}
onload = function()
{
  // 开始检查订单
  startCheckOrder();
}

function validate()
{
  var validator = new Validator('theForm');
  validator.required('title', no_title);
{/literal}
{if $tvd.cat_id >= 0}
  validator.isNullOption('tvd_cat',no_cat);
{/if}
{literal}

  return validator.passed();
}

document.getElementById("tabbar-div").onmouseover = function(e)
{
    var obj = Utils.srcElement(e);

    if (obj.className == "tab-back")
    {
        obj.className = "tab-hover";
    }
}

document.getElementById("tabbar-div").onmouseout = function(e)
{
    var obj = Utils.srcElement(e);

    if (obj.className == "tab-hover")
    {
        obj.className = "tab-back";
    }
}

document.getElementById("tabbar-div").onclick = function(e)
{
    var obj = Utils.srcElement(e);

    if (obj.className == "tab-front")
    {
        return;
    }
    else
    {
        objTable = obj.id.substring(0, obj.id.lastIndexOf("-")) + "-table";

        var tables = document.getElementsByTagName("table");
        var spans  = document.getElementsByTagName("span");

        for (i = 0; i < tables.length; i++)
        {
            if (tables[i].id == objTable)
            {
                tables[i].style.display = (Browser.isIE) ? "block" : "table";
            }
            else
            {
                tables[i].style.display = "none";
            }
        }
        for (i = 0; spans.length; i++)
        {
            if (spans[i].className == "tab-front")
            {
                spans[i].className = "tab-back";
                obj.className = "tab-front";
                break;
            }
        }
    }
}

function showNotice(objId)
{
    var obj = document.getElementById(objId);

    if (obj)
    {
        if (obj.style.display != "block")
        {
            obj.style.display = "block";
        }
        else
        {
            obj.style.display = "none";
        }
    }
}

function searchGoods()
{
    var elements  = document.forms['theForm'].elements;
    var filters   = new Object;

    filters.cat_id = elements['cat_id'].value;
    filters.brand_id = elements['brand_id'].value;
    filters.keyword = Utils.trim(elements['keyword'].value);

    sz.loadOptions('get_goods_list', filters);
}
{/literal}

/**
 * 选取上级分类时判断选定的分类是不是底层分类
 */
function catChanged()
{
  var obj = document.forms['theForm'].elements['tvd_cat'];

  cat_type = obj.options[obj.selectedIndex].getAttribute('cat_type');
  if (cat_type == undefined)
  {
    cat_type = 1;
  }

  if ((obj.selectedIndex > 0) && (cat_type == 2 || cat_type == 4))
  {
    alert(not_allow_add);
    obj.selectedIndex = 0;
    return false;
  }

  return true;
}

  /**
   * 增加扩展分类
   */
  function addOtherCat(conObj)
  {
      var sel = document.createElement("SELECT");
      var selCat = document.forms['theForm'].elements['tvd_cat'];

      for (i = 0; i < selCat.length; i++)
      {
          var opt = document.createElement("OPTION");
          opt.text = selCat.options[i].text;
          opt.value = selCat.options[i].value;
          if (Browser.isIE)
          {
              sel.add(opt);
          }
          else
          {
              sel.appendChild(opt);
          }
      }
      conObj.appendChild(sel);
      sel.name = "other_cat[]";
      sel.onChange = function() {checkIsLeaf(this);};
  }

</script>
{include file="pagefooter.htm"}